﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
    <title>班级设定</title>
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";

    $(function (){
    
    	$("#date").ligerDateEditor();
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        //if(viewType=="modify"){
        	 $("#clsId").attr("readonly", "readonly").removeAttr("validate");
        //}
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);
        
        //调整form-bar
        $(".form-bar").css("width","560px");

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("clsList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>

<body>
    <form name="mainform" method="post" id="mainform" action="${ctx }/qso/cls/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top: 10px; margin-left: 15px;">
            <tr>
                <td align="right" class="l-table-edit-td" style="width:15%;">班级编号:</td>
                <td align="left" class="l-table-edit-td" style="width:35%;">
                	${command.clsId}
                	<input name="clsId" type="hidden" id="clsId" value="${command.clsId}" ltype="text" />
                </td>
                <td align="right" class="l-table-edit-td" style="width:15%;">院系名称:</td>
                <td align="left" class="l-table-edit-td" style="width:35%;">
                	<select style="width: 180px" name="deptId" id="deptId" ltype="select" validate="{required:true}" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if>>
                	 	<c:forEach items="${deptList}" var="dept">
                	 		<c:choose>
                	 			<c:when test="${command.dept.id eq dept.id}">
                	 				<option value="${dept.id}" selected="selected">${dept.title}</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${dept.id}">${dept.title}</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 	</c:forEach>
                	 </select> 
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td" style="width:15%;">年级名称:</td>
                <td align="left" class="l-table-edit-td" style="width:35%;">
                	<select style="width: 180px" name="gradeId" id="gradeId" ltype="select" validate="{required:true}" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if>>
                	 	<c:forEach items="${gradeList}" var="grade">
                	 		<c:choose>
                	 			<c:when test="${command.grade.gradeId eq grade.gradeId}">
                	 				<option value="${grade.gradeId}" selected="selected">${grade.gradeTitle}</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${grade.gradeId}">${grade.gradeTitle}</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 	</c:forEach>
                	 </select> 
                </td>
                <td align="right" class="l-table-edit-td" style="width:15%;">班级名称:</td>
                <td align="left" class="l-table-edit-td" style="width:35%;">
                	<input name="clsTitle" type="text" id="clsTitle" value="${command.clsTitle}"  format="yyyy" validate="{required:true}" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if>/>
                </td>                
            </tr> 
		</table>		
    </form>
</body>
</html>
